﻿<ui:VsDialogWindow
    x:Class="NuGet.Client.VisualStudio.UI.LicenseAcceptanceWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:resx="clr-namespace:NuGet.Client.VisualStudio.UI.Resources"
    xmlns:ui="clr-namespace:NuGet.Client.VisualStudio.UI"
    x:Name="_self"
    MinWidth="450"
    MinHeight="450"
    Width="450"
    Height="450"
    mc:Ignorable="d"
    ShowInTaskbar="False"
    WindowStartupLocation="CenterOwner"
    Title="{x:Static resx:Resources.WindowTitle_LicenseAcceptance}"
    d:DesignHeight="300" d:DesignWidth="300">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <DataTemplate x:Key="LicenseItemTemplate">
                <StackPanel Margin="2,0,2,5">
                    <TextBlock TextWrapping="Wrap">
                    <Run Text="{Binding Id, Mode=OneTime}" FontWeight="Bold" />
                    <Run Text=" " />
                    <Run Text="Authors: " />
                    <Run Text="{Binding Authors, Mode=OneTime}" />
                    </TextBlock>
                    <TextBlock AutomationProperties.AutomationId="{Binding Id, Mode=OneWay, StringFormat='LicenseTerm_{0}'}">
                    <Hyperlink AutomationProperties.AutomationId="{Binding Id, Mode=OneWay, StringFormat='LicenseTermLink_{0}'}" 
                               NavigateUri="{Binding LicenseUrl, Mode=OneTime}"  
                               Style="{StaticResource HyperlinkStyle}"
                               RequestNavigate="OnViewLicenseTermsRequestNavigate">
                        <Run Text="View License" />
                    </Hyperlink>
                    </TextBlock>
                </StackPanel>
            </DataTemplate>
        </ResourceDictionary>        
    </Window.Resources>
    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TextBlock 
            Grid.Row="0"
            Margin="12,8,12,0"
            Text="{x:Static resx:Resources.Text_LicenseAcceptance}"
            FontSize="{Binding ElementName=_self,Path=FontSize,Converter={StaticResource Font122PercentSizeConverter}}" />
        
        <TextBlock
            Grid.Row="1"
            Margin="12,4,12,0"
            Text="{x:Static resx:Resources.Text_LicenseHeaderText}" 
            TextWrapping="Wrap"/>
            
        <ItemsControl
            Grid.Row="2"
            Margin="12,8"
            MinHeight="130"
            IsTabStop="False"
            ItemsSource="{Binding}"
            ItemTemplate="{StaticResource LicenseItemTemplate}">
            <ItemsControl.Template>
                <ControlTemplate TargetType="{x:Type ItemsControl}">
                    <Border BorderThickness="1" BorderBrush="{DynamicResource {x:Static resx:Brushes.BorderBrush}}">
                        <ScrollViewer
                            Padding="3"
                            Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
                            CanContentScroll="True"
                            VerticalScrollBarVisibility="Visible"
                            HorizontalScrollBarVisibility="Disabled">
                            <ItemsPresenter></ItemsPresenter>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </ItemsControl.Template>
        </ItemsControl>
        <TextBlock Grid.Row="3"
                   Margin="12,0,12,12"
                   Text="{x:Static resx:Resources.Text_LicenseText}"
                   TextWrapping="Wrap" ></TextBlock>
        
        <Grid 
            Grid.Row="5"
            Background="{Binding ElementName=_self, Path=Background}" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>
            
            <Button
                Grid.Column="1"
                MinWidth="86"
                MinHeight="24"
                Margin="0,12"
                Content="{x:Static resx:Resources.Button_IAccept}" 
                AutomationProperties.AutomationId="AcceptButton"
                Click="OnAcceptButtonClick" />
            <Button 
                Grid.Column="2"
                MinWidth="86"
                MinHeight="24"
                Margin="6,12,12,12"
                Content="{x:Static resx:Resources.Button_IDecline}" 
                AutomationProperties.AutomationId="DeclineButton"
                Click="OnDeclineButtonClick" />

        </Grid>
    </Grid>
</ui:VsDialogWindow>